package Interface;

interface IFlying {
    void fly();
}
interface IRunning {
    void run();
}
interface ISwimming {
    void swim();
}
class Animal{
    public String name;
    public Animal(String name){
        this.name=name;
    }
}
//先继承在实现接口
class Cat extends Animal implements IRunning{
    public Cat(String name){
        super(name);
    }

    @Override
    public void run() {
        System.out.println(this.name+"正在跑步");
    }
}
class Bird extends Animal implements IRunning,IFlying{
    public Bird(String name){
        super(name);
    }
    @Override
    public void run() {
        System.out.println(this.name+"正在跑步");
    }
    @Override
    public void fly() {
        System.out.println(this.name+"正在飞");
    }
}
class Duck extends Animal implements IRunning,ISwimming,IFlying{
    public Duck(String name){
        super(name);
    }
    @Override
    public void run() {
        System.out.println(this.name+"正在跑步");
    }
    @Override
    public void swim() {
        System.out.println(this.name+"正在游泳");
    }
    @Override
    public void fly() {
        System.out.println(this.name+"正在飞");
    }
}
class Robot implements IRunning{
    @Override
    public void run() {
        System.out.println("机器人正在跑");
    }
}
public class MoreExtends {
    public static void funcIRun(IRunning iRunning){
        iRunning.run();
    }
    public static void funcIFly(IFlying iFlying){
        iFlying.fly();
    }
    public static void funcISwim(ISwimming iSwimming){
        iSwimming.swim();
    }
    public static void main(String[] args) {
        /*IRunning iRunning=new Cat("小猫咪");
        iRunning.run();
        IRunning iRunning1=new Bird("小鸟");
        iRunning1.run();
        IRunning iRunning2=new Duck("小鸭子");
        iRunning2.run();*/
        funcIRun(new Cat("小猫咪"));
        funcIRun(new Bird("小鸟"));
        funcIRun(new Duck("小鸭子"));
        funcIRun(new Robot());//不管传过来的是什么，只要实现了这个接口，就可以调用

        funcIFly(new Bird("小鸟"));
        funcIFly(new Duck("小鸭子"));

        funcISwim(new Duck("小鸭子"));
    }
    public static void main1(String[] args) {
        Animal animal=new Cat("小猫咪");
        Animal animal2=new Bird("小鸟");
        Animal animal3=new Duck("小鸭子");

    }
}
